home *** CD-ROM | disk | FTP | other *** search
- Path: news.mcs.net!mdp
- From: mdp@mika-sys.com (Michael D. Perry)
- Newsgroups: comp.lang.c
- Subject: Re: What the heck is ...?
- Date: Mon, 12 Feb 96 06:14:16 GMT
- Organization: MIKA Systems
- Message-ID: <4fmlro$nfg_001@pr.mcs.net>
- References: <sconi-1102961642580001@ip-24.newportnet.net>
- NNTP-Posting-Host: mdp.pr.mcs.net
- X-Newsreader: News Xpress Version 1.0 Beta #4
-
- In article <sconi-1102961642580001@ip-24.newportnet.net>,
- sconi@superstore.com (Chris Tiee "Chochoni Boboni") wrote:
- >Here's something all the books love to avoid: The use of ... in
- function
- >declarations. For example, one book says that the prototype of
- printf() is
- >
- >int printf(const char *fmt_string, ...);
- >
-
- << SNIP >>
-
- What the ellipses mean is that it is a repeatable item. In the
- case that you cite it takes the place of saying that all of the
- following statements are valid:
-
- printf("This is a test");
- /* Note the lack of a comma */
-
- int a = 2;
- printf("This is test number %d", a);
-
- Prints: This is test number 2
- /* Where the '%d' is a format specifier, and 'a' is a
- numeric variable */
-
- printf("This is test number %d", 2);
- /* Prints exactly the same as the line above except does
- not use a variable */
-
- int a = 2;
- int b = 3;
- printf("Test %d, is followed by test %d", a b);
- Prints: Test 2 is followed by test 3
-
- So logic follow that:
-
- printf("%d, %d, %d, %d, %d, %d, %d", 1 2 3 4 5 6 7);
-
- is the same as:
-
- printf("%d, ..., %d", 1 ... 7);
-
- and is simply much easier to type and accounts for any number of
- variables.
-
- -------------------------------------------------------------------
- Michael D. Perry | FIRST RULE OF INTELLIGENT TINKERING:
- MIKA Systems | Save all the parts.
- Glen Ellyn, Illinois | SATTINGER'S LAW:
- mdp@mika-sys.com | It works better if you plug it in.
- -------------------------------------------------------------------
-